#OUTDIR = /kf/nfs
OUTDIR = ~/share/tftpdir/v4l2

APP_1 = file_save
APP_2 = net_send
APP_3 = plate_recogn
APP_4 = plate_recogn_android

APP = $(APP_1)

OBJS_1 = file_save.o semlock.o video.o format.o bitmap.o fileio.o
OBJS_2 = net_send.o
OBJS_3 = plate_recogn.o
OBJS_4 = plate_recogn_android.o

DEFINE_1 = -DV4L2_FORMAT=V4L2_PIX_FMT_RGB32 #-DVIDEO_SWITCH
DEFINE_2 =
DEFINE_3 =
DEFINE_4 =
DEFINE = $(DEFINE_1)

INCLUDE_1 =
INCLUDE_2 =
INCLUDE_3 =
INCLUDE_4 =
INCLUDE = $(INCLUDE_1)

SLIB_1 =
SLIB_2 =
SLIB_3 =
SLIB_4 =

DLIB_1 = -lpthread
DLIB_2 = -lpthread
DLIB_3 =
DLIB_4 =

ARCH ?= arm-linux-

CC = $(ARCH)g++

all: $(APP_1)
	@echo "\033[33mCOPY\033[0m $^ ---> $(OUTDIR)"
	@cp -raf $^ $(OUTDIR)

$(APP_1): $(OBJS_1)
	@echo "\033[33mLINK\033[0m $@ <--- $^"
	@$(CC) -Wall -o $@ $^ $(SLIB_1) $(DLIB_1)

$(APP_2): $(OBJS_2)
	@echo "\033[33mLINK\033[0m $@ <--- $^"
	@$(CC) -Wall -o $@ $^ $(SLIB_2) $(DLIB_2)

$(APP_3): $(OBJS_3)
	@echo "\033[33mLINK\033[0m $@ <--- $^"
	@$(CC) -Wall -o $@ $^ $(SLIB_3) $(DLIB_3)

$(APP_4): $(OBJS_4)
	@echo "\033[33mLINK\033[0m $@ <--- $^"
	@$(CC) -Wall -o $@ $^ $(SLIB_4) $(DLIB_4)

%.o: %.c
	@echo "\033[32mBUILD\033[0m $@"
	@$(CC) -Wall $(INCLUDE) $(DEFINE) -c -o $@ $<

clean:
	@echo "\033[31mCLEAN\033[0m"
	@rm -rf $(APP_1) $(APP_2) $(APP_3) $(APP_4) *.o *.i
